*****************************************
*** ONLINE APPENDIX: SOCIAL DIVISIONS ***
*****************************************

*NOTE: This do-file should be executed on the dataset: "individual-level-data"
*NOTE: To reproduce the online appendix, please use Stata 15 with the following packages installed:
ssc install blidschemes
ssc install grc1leg
ssc install estout
ssc install coefplot
*NOTE: If packages are already installed, run the do-file from here

xtset year

*** Figure A1 ***
*Predicted probabilities of Labour support plottet over time
logit votelab class4##year if year>=1964 & bsabes==1
margins, over(year class4)
marginsplot, noci xlabel(1965 (10) 2015) ///
	ylabel(0 (.1) 1) ytitle("Predicted Labour support") xtitle("") title("")

*** Figure A2 *** 
*(see the other replication files on Dataverse: "online-appendix-2")

*** Table A1 ***
*Descriptive statistics for categories in the group emphasis dataset
*(see the other replication files on Dataverse: "online-appendix-4")

*** Figure A3 ***
*The development of Labour's group-based and policy-based class appeals, 1964-2015
twoway connected ilworkerpos year if bsabes==1 & year>=1964, ylabel(0 (2) 10) msymbol(O) ///
xlabel(1965 (25) 2015, angle(0)) ytitle("") xtitle("") title("Workers (%)") name(workers, replace)

twoway connected ilbusinesspos year if bsabes==1 & year>=1964, ylabel(0 (2) 10) msymbol(O) /// 
xlabel(1965 (25) 2015, angle(0)) ytitle("") xtitle("") title("Businesses (%)") name(businesses, replace)

twoway connected ilecon year if bsabes==1 & year>=1964, ylabel(-40 (10) 0) msymbol(O) /// 
xlabel(1965 (25) 2015, angle(0)) ytitle("") xtitle("") title("Economic position (score)") name(econposition, replace)

twoway connected ipolarecon year if bsabes==1 & year>=1964, ylabel(0 (10) 60) msymbol(O) /// 
xlabel(1965 (25) 2015, angle(0)) ytitle("") xtitle("") title("Economic difference (score)") name(econdifference, replace)

grc1leg workers businesses econposition econdifference, rows(1) ///
	 title("") subtitle("") name(trends, replace)

*** Table A2 ***
*Correlations between policy and group indicators
pwcorr ilworkerpos ilbusinesspos ilecon stdworkerpolpos stdbusinesspolpos ipolarecon if bsabes==1 & year>=1964

*** Table A3 ***
*Main effects of social class position and class appeals on Labour support
estimates clear
eststo: xtlogit votelab i.class4w c.ilworkerpos if bsabes==1, re
eststo: xtlogit votelab i.class4w c.ilbusinesspos if bsabes==1, re
eststo: xtlogit votelab i.class4w c.ilecon if bsabes==1, re
eststo: xtlogit votelab i.class4w c.ipolarecon if bsabes==1, re
esttab

*** Figure A4 *** 
*Plot of standardized interaction effects using Labour-Conservative differences
estimates clear
mat model=J(4,3,.)

xtreg votelab i.class2##c.stdworkerpolpos i.class2##c.stdecon i.class2##c.stdpolarecon if bsabes==1, re	
mat output=r(table)'
mat model[1,1]=output[5,1]
mat model[1,2]=output[5,5]
mat model[1,3]=output[5,6]

xtreg votelab i.class2##c.stdbusinesspolpos i.class2##c.stdecon i.class2##c.stdpolarecon if bsabes==1, re	
mat output=r(table)'
mat model[2,1]=output[5,1]
mat model[2,2]=output[5,5]
mat model[2,3]=output[5,6]

xtreg votelab i.class2##c.stdecon i.class2##c.stdworkerpolpos i.class2##c.stdbusinesspolpos if bsabes==1, re
mat output=r(table)'
mat model[3,1]=output[5,1]
mat model[3,2]=output[5,5]
mat model[3,3]=output[5,6]

xtreg votelab i.class2##c.stdpolarecon i.class2##c.stdworkerpolpos i.class2##c.stdbusinesspolpos if bsabes==1, re	
mat output=r(table)'
mat model[4,1]=output[5,1]
mat model[4,2]=output[5,5]
mat model[4,3]=output[5,6]

mat list model
matrix rownames model= 1 2 3 4

coefplot (matrix(model [.,1]), ci((model [.,2] model [.,3]))), byopts(xrescale)  ///
coeflabels(1 = `""Worker emphasis difference" "({&Delta} st.d.)""' 2 = `""Business emphasis difference" "({&Delta} st.d.)""' 3 = `""Economic position"  "({&Delta} st.d.)""' 4 = `""Economic difference" "({&Delta} st.d.)""', labgap(4) labsize(medsmall)) ///
xline(0, lwidth(vthin) lpattern(dash) lcolor(black)) grid(none)  xlabel(-0.05(0.01)0.05) ///
citop ciopts(recast(rcap)) levels(95) msymbol(O) xtitle("Change to the 'class gap'")

*** Figure A5 ***
*Plot of standardized interaction effects using partisanship as dependent variable
estimates clear
mat model=J(4,3,.)

xtreg pidlab i.class2##c.stdworkerpos i.class2##c.stdecon i.class2##c.stdpolarecon i.sex age, re	
mat output=r(table)'
mat model[1,1]=output[5,1]
mat model[1,2]=output[5,5]
mat model[1,3]=output[5,6]

xtreg pidlab i.class2##c.stdbusinesspos i.class2##c.stdecon i.class2##c.stdpolarecon i.sex age, re	
mat output=r(table)'
mat model[2,1]=output[5,1]
mat model[2,2]=output[5,5]
mat model[2,3]=output[5,6]

xtreg pidlab i.class2##c.stdecon i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age, re
mat output=r(table)'
mat model[3,1]=output[5,1]
mat model[3,2]=output[5,5]
mat model[3,3]=output[5,6]

xtreg pidlab i.class2##c.stdpolarecon i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age, re	
mat output=r(table)'
mat model[4,1]=output[5,1]
mat model[4,2]=output[5,5]
mat model[4,3]=output[5,6]

mat list model
matrix rownames model= 1 2 3 4 

coefplot (matrix(model [.,1]), ci((model [.,2] model [.,3]))), byopts(xrescale) ///
coeflabels(1 = `""Worker emphasis" "({&Delta} st.d.)""' 2 = `""Business emphasis" "({&Delta} st.d.)""' 3 = `""Economic position" "({&Delta} st.d.)""' 4 = `""Economic difference" "({&Delta} st.d.)""', labgap(4) labsize(medsmall)) ///
xline(0, lwidth(vthin) lpattern(dash) lcolor(black)) grid(none)  xlabel(-0.05(0.01)0.05) ///
citop ciopts(recast(rcap)) levels(95) msymbol(O) xtitle("Change to the 'class gap'")

*** Table A4 ***
*Main results using household income to measure class
estimate clear
eststo: xtlogit votelab i.income5##c.ilworkerpos income5##c.ilecon income5##c.ipolarecon i.sex age if bsabes==1, re
eststo: xtlogit votelab i.income5##c.ilbusinesspos income5##c.ilecon income5##c.ipolarecon i.sex age if bsabes==1, re
esttab

*** Table A5 ***
*The effect of poor people emphasis on class voting
estimate clear
eststo: xtlogit votelab i.class4w##c.ilpoorpos class4w##c.ilecon class4w##c.ipolarecon i.sex age if bsabes==1, re
eststo: xtlogit votelab i.income5##c.ilpoorpos income5##c.ilecon income5##c.ipolarecon i.sex age if bsabes==1, re
esttab
 
*** Figure A6 ***
*Plot of standardized interaction effects using RILE to measure policy
mat model=J(8,3,.)

xtreg votelab i.class2##c.stdworkerpos i.class2##c.stdrile i.class2##c.stdpolar i.sex age if bsabes==1, re	
mat output=r(table)'
mat model[1,1]=output[5,1]
mat model[1,2]=output[5,5]
mat model[1,3]=output[5,6]

xtreg votelab i.class2##c.stdbusinesspos i.class2##c.stdrile i.class2##c.stdpolar i.sex age if bsabes==1, re	
mat output=r(table)'
mat model[2,1]=output[5,1]
mat model[2,2]=output[5,5]
mat model[2,3]=output[5,6]

xtreg votelab i.class2##c.stdrile i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age if bsabes==1, re
mat output=r(table)'
mat model[3,1]=output[5,1]
mat model[3,2]=output[5,5]
mat model[3,3]=output[5,6]

xtreg votelab i.class2##c.stdpolar i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age if bsabes==1, re	
mat output=r(table)'
mat model[4,1]=output[5,1]
mat model[4,2]=output[5,5]
mat model[4,3]=output[5,6]

xtreg pidlab i.class2##c.stdworkerpos i.class2##c.stdrile i.class2##c.stdpolar i.sex age, re	
mat output=r(table)'
mat model[5,1]=output[5,1]
mat model[5,2]=output[5,5]
mat model[5,3]=output[5,6]

xtreg pidlab i.class2##c.stdbusinesspos i.class2##c.stdrile i.class2##c.stdpolar i.sex age, re	
mat output=r(table)'
mat model[6,1]=output[5,1]
mat model[6,2]=output[5,5]
mat model[6,3]=output[5,6]

xtreg pidlab i.class2##c.stdrile i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age, re
mat output=r(table)'
mat model[7,1]=output[5,1]
mat model[7,2]=output[5,5]
mat model[7,3]=output[5,6]

xtreg pidlab i.class2##c.stdpolar i.class2##c.stdworkerpos i.class2##c.stdbusinesspos i.sex age, re	
mat output=r(table)'
mat model[8,1]=output[5,1]
mat model[8,2]=output[5,5]
mat model[8,3]=output[5,6]

mat list model

matrix rownames model = 1 2 3 4 5 6 7 8

coefplot (matrix(model [.,1]), ci((model [.,2] model [.,3]))), byopts(xrescale) ///
coeflabels(1 = `""Worker emphasis  " "({&Delta} st.d.)  ""' 2 = `""Business emphasis  " "({&Delta} st.d.)  ""' 3 = `""RILE position  " "({&Delta} st.d.)  ""' 4 = `""RILE difference  " "({&Delta} st.d.)  ""' ///
5 = `""Worker emphasis  " "({&Delta} st.d.)  ""' 6 = `""Business emphasis  " "({&Delta} st.d.)  ""' 7 = `""RILE position  " "({&Delta} st.d.)  ""' 8 = `""RILE difference " "({&Delta} st.d.) ""', labsize(small)) ///
headings(1 = "{bf:DV: Vote choice  }" 5 = "{bf:DV: Partisanship  }") graphregion(margin(l=25)) ///
xline(0, lwidth(vthin) lpattern(dash) lcolor(black)) grid(none) graphregion(margin(l=15)) xlabel(-0.06(0.01)0.06) ///
citop ciopts(recast(rcap)) levels(95) msymbol(O) xtitle("Change to the 'class gap'")


*** Table A6 ***
* Main results controlling for GDP per capita growth
estimates clear
eststo: xtlogit votelab i.class4w##c.ilworkerpos i.class4w##c.ilecon i.class4w##c.ipolarecon i.class4w##c.gdp i.sex age if bsabes==1, re
eststo: xtlogit votelab i.class4w##c.ilbusinesspos i.class4w##c.ilecon i.class4w##c.ipolarecon i.class4w##c.gdp i.sex age if bsabes==1, re
esttab 

*** Table A7 ***
*(see the other replication files on Dataverse: "online-appendix-3")

*** Table A8 ***
*(see the other replication files on Dataverse: "online-appendix-3")

*** Table A9 ***
estimates clear
eststo: xtlogit votelab i.class4w##c.ilworkerpos##c.ilecon i.sex age if bsabes==1, re
eststo: xtlogit votelab i.class4w##c.ilworkerpos##c.ipolarecon i.sex age if bsabes==1, re
eststo: xtlogit votelab i.class4w##c.ilbusinesspos##c.ilecon i.sex age if bsabes==1, re
eststo: xtlogit votelab i.class4w##c.ilbusinesspos##c.ipolarecon i.sex age if bsabes==1, re
esttab 

*END OF DO-FILE
